const tk = '974d3f8fd3cba3f83d098b4220669a93'
const errorTileUrl = './imgs/gis/null.png'

export function init (dom) {
    const map = L.map(dom, {
        preferCanvas: true,
        positionControl: false,
        attributionControl: false,
        zoomControl: false,
        zoomSnap: window.devicePixelRatio > 1 ? 0.5 : 0.1,
        scrollWheelZoom: true,
        dragging: true,
        keyboard: false,
        touchZoom: true,
        doubleClickZoom: true,
        boxZoom: true,
        tap: true,
        maxBoundsViscosity: 1,
        zoom: 10,
        center: [25.87524527709376, 114.89366983570925]
    })
    L.tileLayer(`https://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=${tk}`, {
        subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
        minZoom: 4,
        maxZoom: 21,
        maxNativeZoom: window.devicePixelRatio > 1 ? 17 : 18,
        detectRetina: true,
        errorTileUrl
    }).addTo(map)
    L.tileLayer(`https://t{s}.tianditu.gov.cn/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=${tk}`, {
        subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
        minZoom: 5,
        maxZoom: 21,
        maxNativeZoom: window.devicePixelRatio > 1 ? 17 : 18,
        detectRetina: true,
        errorTileUrl
    }).addTo(map)
    return map
}
